#include <stdio.h>
#include <sysinfo.h>

int main(int argc, char *argv[])
{


    getstat(cpu_use,cpu_nic, cpu_sys, cpu_idl, cpu_iow, cpu_xxx, \
            cpu_yyy, cpu_zzz, pgpgin, pgpgout, pswpin, pswpout, \
            intr, ctxt, &running,&blocked, &dummy_1, &dummy_2);

    float cpuconsumption = (float) ((   (float) ((*cpu_use) + (*cpu_sys)) / (float)((*cpu_use)+(*cpu_sys)+(*cpu_idl)))*100);

    printf("cpu %f\n", cpuconsumption);
#if 0
    struct sysinfo s_info; 
    int error; 

    error = sysinfo(&s_info); 

    printf("\n\ncode error=%d\n",error); 
    printf("Uptime = %lus\nLoad: 1 min %lu / 5 min %lu / 15 min %lu\n"
            "RAM: total %lu / free %lu /shared %lu\n" 
            "Memory in buffers = %lu\nSwap:total %lu/free %lu\n" 
            "Number of processes = %lu\n",
            s_info.uptime, s_info.loads[0], 
            s_info.loads[1], s_info.loads[2], 
            s_info.totalram, s_info.freeram, 
            s_info.totalswap, s_info.freeswap, 
            s_info.procs); 
#endif
    return 0;
}
